package com.hanxiaozhang.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;


/**
 * 功能描述: <br>
 * 〈SpringMVC配置〉
 *
 * @Author:hanxinghua
 * @Date: 2021/5/3
 */
@Slf4j
@Configuration
public class SpringMvcConfig implements WebMvcConfigurer {

    @Value("${hanxiaozhang.baseFilePath}")
    private String baseFilePath;


    /**
     * 配置文件的位置
     *
     * @param registry
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {


        //addResourceHandler-->URL中地址，addResourceLocations-->图片在图片服务器中地址
        registry.addResourceHandler("/files/**").addResourceLocations("file:"+baseFilePath);
    }


}
